﻿using NORM.Entity;
using NORM.SQLObject;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace NORM.Demo
{
    public partial class 迸发测试 : Form
    {
        public 迸发测试()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            dd2();
            dd1();           
        }

        private void dd1()
        {
            System.Threading.Thread[] ths = {
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                     new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler)),
                    new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(Handler))
                                                };

            for (int i = 0; i < ths.Length; i++)
            {
                ths[i].IsBackground = true;
            }

            for (int i = 0; i < ths.Length; i++)
            {
                ths[i].Start(i);
            }
        }

       

        private void Handler(object id)
        {
            try
            {
                //NORM.Logger.LoggerHelper.Debug(id + "开始执行", DateTime.Now.ToString());
                var connectionString = "Server=(Local);Initial Catalog=DevelopFramework_Demo;User ID=sa;Pwd=123456;";
                using (var db = NORM.DataBase.DataBaseFactory.Create(connectionString, DataBase.DataBaseTypes.SqlDataBase))
                {
                    //Models.T_Sys_Logger model = new Models.T_Sys_Logger();
                    //OQL oql = OQL.From(model)
                    //    .Where(w => w.Compare(model.Type, "=", 4) && w.Compare(model.Datetime, ">", "2017-12-09 12:38:52.020")) //DateTime.Now.AddDays(-30)
                    //    .OrderBy(O => O.Asc(model.Datetime))
                    //    .Select(() => {
                    //        return new { 
                    //           model.Content,
                    //           model.IpAddress,
                    //           model.OperationBy,
                    //           model.Describtion,
                    //           model.Datetime
                    //        };
                    //    })
                    //    .End;


                    //model.Type = 4;
                    //model.StateCode = "500";
                    //OQL oql2 = new OQL(model)
                    //    .Update(m => m.Set(model.Type) && m.Set(model.StateCode))
                    //    .Where(w => w.Compare(model.ID, "=", id)).End;

                    //EntityQuery<Models.T_Sys_Logger>.Instance.Excute(oql2, db);

                    //var list = EntityQuery<Models.T_Sys_Logger>.Instance.QueryList(oql, db);
                    //string name = list.Count > 0 ? list[0].Content : "";
                    //NORM.Logger.LoggerHelper.Debug(id + ":" + name + " 执行成功", DateTime.Now.ToString());

                    Models.T_Sys_Users model1 = new Models.T_Sys_Users();
                    Models.T_Sys_Roles model2 = new Models.T_Sys_Roles();

                    OQL oql = OQL.From(model1).LeftJoin(model2).ON(model1.RoleID, model2.ID)
                        //.Where(model1.Level, 0)
                        //.And(model2.ID, 1)
                        .Where(w => w.Compare(model1.Level, "=", 0))
                        .OrderBy(O => O.Asc(model1.ID))
                        .Select(() =>
                        {
                            return new
                            {
                                model1.ID,
                                model1.Name,
                                model1.Level,
                                model2.Label,
                                model2.Note
                            };
                        }).End;

                    //var data = db.QueryTable(oql);
                    //var list = EntityQuery<Models.T_Sys_Users>.Instance.QueryList(oql, db);

                    Models.T_City model3 = new Models.T_City();
                    Models.T_Province model4 = new Models.T_Province();

                    OQL oql2 = OQL.From(model3).Join(model4).ON(model3.ProvinceId, model4.ID)
                        .Where(model4.ID, 1)
                        .And(model4.ID,1)
                        .OrderBy(o => o.Desc(model3.ID))
                        .Select( ()=> {
                            return new { 
                                model3.ID,
                                model3.Name,
                                model3.Code,
                                model4.Describe
                            };
                        })                       
                        .End;

                    var list = EntityQuery<Models.T_Sys_Users>.Instance.QueryToList(oql2, db);

                    NORM.Logger.LoggerHelper.Debug(id + ":" +list.Count +   " 执行成功", DateTime.Now.ToString());
                }
            }
            catch (Exception ex)
            {
                NORM.Logger.LoggerHelper.Error(id + "执行中出现错误:" + ex.Message, DateTime.Now.ToString(), ex.StackTrace);
            }
        }

        private void Handler2(object id)
        {
            try
            {
                //NORM.Logger.LoggerHelper.Debug(id + "开始执行", DateTime.Now.ToString());
                var connectionString = "Server=(Local);Initial Catalog=DevelopFramework_Demo;User ID=sa;Pwd=123456;";
                using (var db = NORM.DataBase.DataBaseFactory.Create(connectionString, DataBase.DataBaseTypes.SqlDataBase))
                {
                    Models.T_Sys_Logger model = new Models.T_Sys_Logger();
                    OQL oql = OQL.From(model)
                        .Where(w => w.Compare(model.Type, "=", 1) && w.Compare(model.Datetime, ">", "2017-12-09 12:38:52.020"))
                        .OrderBy(O => O.Asc(model.Datetime))
                        .Select()
                        .End;


                    model.Type = 4;
                    model.StateCode = "500";
                    OQL oql2 = OQL.Update(model)
                        .Set(() => new { model.Type, model.StateCode }) //m => m.Set(model.Type) && m.Set(model.StateCode)
                        .Where(w => w.Compare(model.ID, "=", id)).End;

                    EntityQuery<Models.T_Sys_Logger>.Instance.Excute(oql2, db);


                    var list = EntityQuery<Models.T_Sys_Logger>.Instance.QueryToList(oql, db);
                    NORM.Logger.LoggerHelper.Debug(id + "执行成功", DateTime.Now.ToString());
                }
            }
            catch (Exception ex)
            {
                NORM.Logger.LoggerHelper.Error(id + "执行中出现错误:" + ex.Message, DateTime.Now.ToString(), ex.StackTrace);
            }
        }

        private void dd2()
        {
            var connectionString = "Server=(Local);Initial Catalog=DevelopFramework_Demo;User ID=sa;Pwd=123456;";
            using (var db = NORM.DataBase.DataBaseFactory.Create(connectionString, DataBase.DataBaseTypes.SqlDataBase))
            {
                Models.T_Sys_Logger model = new Models.T_Sys_Logger();

                //OQL oql = OQL.From(model).Where(w => w.Compare(model.Type, "=", 4))
                //    .OrderBy(o => o.Asc(model.Datetime))
                //    .Select(() =>
                //    {
                //        return new { ID = model.ID, Content = model.Content };
                //    })
                //    .Limit(3).End;


                OQL oql = OQL.From(model).Where(w => w.Compare(model.Type, "=", 4))
                   .OrderBy(o => o.Asc(model.Datetime))
                   .Select(() =>
                   {
                       return new { model.ID, model.Content };
                   })
                   .Limit(3).End; 

                var list = EntityQuery<Models.T_Sys_Logger>.Instance.QueryToList(oql, db);
                var data = db.QueryList<Models.T_Sys_Logger>(oql);
            }
           
        }

    }
}
